package rs.dalao.syc.index.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rs.dalao.syc.common.response.JsonResult;
import rs.dalao.syc.index.pojo.vo.HotDetailVO;
import rs.dalao.syc.index.pojo.vo.VaccineListVO;
import rs.dalao.syc.index.pojo.vo.VacDetailsVO;
import rs.dalao.syc.index.service.IVaccineService;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/vaccine/")
@Api(tags = "2. 疫苗管理")
public class VaccineController {

    @Autowired
    private IVaccineService vaccineService;


    public VaccineController() {
        log.debug("创建控制器类对象：VaccineController");
    }

    @GetMapping("vaccineList/{type}")
    @ApiOperation("查询疫苗list一类")
    @ApiOperationSupport(order = 201)
    public JsonResult getVaccineList(@PathVariable Integer type) {
        log.debug("开始处理【查询疫苗list】的请求，参数：{}", type);
        List<VaccineListVO> getVaccineList = vaccineService.getVaccineList(type);
        return JsonResult.ok(getVaccineList);
    }

    @GetMapping("{vaccineId}/detail")
    @ApiOperation("疫苗详情页面")
    public JsonResult selectByIdForDetail(@PathVariable Long vaccineId){
        List<VacDetailsVO> vaccineDetail = vaccineService.getVaccineDetail(vaccineId);
        return JsonResult.ok(vaccineDetail);
    }

    @GetMapping("detail/hot")
    @ApiOperation("展示疫苗热门文章")
    public JsonResult selectVaccineHotDetail(){
        List<HotDetailVO> vaccineHotDetailVOS = vaccineService.selectVaccineHotDetail();
        return JsonResult.ok(vaccineHotDetailVOS);
    }
}
